package com.api.tournament.controller;
import com.api.core.controller.Ctrl;
import com.api.core.response.Result;
import com.api.core.response.ResultGenerator;
import com.api.tournament.model.TournamentSponsor;
import com.api.tournament.service.TournamentSponsorService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
import com.api.core.annotation.PowerEnable;
import io.swagger.annotations.*;



/**
* Created by wanghuiwen on 2021/04/16.
*/
@PowerEnable(name = "赞助商",url = "/tournament/sponsor")
@Api(value = "赞助商", tags = {"赞助商"})
@RestController
@RequestMapping("/tournament/sponsor")
public class TournamentSponsorController extends Ctrl{
    @Resource
    private TournamentSponsorService tournamentSponsorService;

    @ApiOperation(value = "赞助商添加", tags = {"赞助商"}, notes = "赞助商添加")
    @PostMapping(value="/add",name="赞助商添加")
    public Result add(@ApiParam TournamentSponsor tournamentSponsor) {
        tournamentSponsorService.save(tournamentSponsor);
        return ResultGenerator.genSuccessResult(tournamentSponsor.getSponsorId());
    }

    @ApiOperation(value = "赞助商删除", tags = {"赞助商"}, notes = "赞助商删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id",required=true, value = "赞助商id", dataType = "Long", paramType = "query")
    })
    @PostMapping(value="/delete",name="赞助商删除")
    public Result delete(@RequestParam Long id) {
        tournamentSponsorService.deleteById(id);
        return ResultGenerator.genSuccessResult();
    }

    @ApiOperation(value = "赞助商修改", tags = {"赞助商"}, notes = "赞助商修改,对象主键必填")
    @PostMapping(value="/update",name="赞助商修改")
    public Result update(@ApiParam TournamentSponsor tournamentSponsor) {
        tournamentSponsorService.update(tournamentSponsor);
        return ResultGenerator.genSuccessResult();
    }
}
